snapshot: Fix graphene misunderstandings
authorBenjamin Otte <otte@redhat.com>
Thu, 17 Nov 2016 00:05:15 +0000 (01:05 +0100)
committerBenjamin Otte <otte@redhat.com>
Thu, 17 Nov 2016 00:05:15 +0000 (01:05 +0100)
The equivalent to cairo_matrix_multiply (a, b, c) is
graphene_matrix_multiply (c, b, a).

graphene_matrix_multiply (a, b, c) may not be called with b and c being
the same matrix.

gtk/gtkrendericon.c
gtk/gtksnapshot.c

index 8ed65e0d9d11d93989d48398799d1773ffdd4b59..a9dc20e0e990b5cc34b5386179025efcefe42dbe 100644 (file)
@@ -91,7 +91,7 @@ gtk_css_style_snapshot_icon (GtkCssStyle            *style,
 {
   const GtkCssValue *shadows, *transform;
   cairo_matrix_t transform_matrix;
-  graphene_matrix_t matrix, other, saved_matrix;
+  graphene_matrix_t m1, m2, m3, saved_matrix;
   GtkCssImage *image;
 
   g_return_if_fail (GTK_IS_CSS_STYLE (style));
@@ -110,14 +110,14 @@ gtk_css_style_snapshot_icon (GtkCssStyle            *style,
   graphene_matrix_init_from_matrix (&saved_matrix, gtk_snapshot_get_transform (snapshot));
 
   /* XXX: Implement -gtk-icon-transform-origin instead of hardcoding "50% 50%" here */
-  graphene_matrix_init_translate (&matrix, &(graphene_point3d_t)GRAPHENE_POINT3D_INIT(width / 2.0, height / 2.0, 0));
-  graphene_matrix_init_from_2d (&other, transform_matrix.xx, transform_matrix.yx,
-                                        transform_matrix.xy, transform_matrix.yy,
-                                        transform_matrix.x0, transform_matrix.y0);
-  graphene_matrix_multiply (&other, &matrix, &matrix);
-  graphene_matrix_init_translate (&other, &(graphene_point3d_t)GRAPHENE_POINT3D_INIT(- width / 2.0, - height / 2.0, 0));
-  graphene_matrix_multiply (&matrix, &other, &matrix);
-  gtk_snapshot_transform (snapshot, &matrix);
+  graphene_matrix_init_translate (&m1, &(graphene_point3d_t)GRAPHENE_POINT3D_INIT(width / 2.0, height / 2.0, 0));
+  graphene_matrix_init_from_2d (&m2, transform_matrix.xx, transform_matrix.yx,
+                                     transform_matrix.xy, transform_matrix.yy,
+                                     transform_matrix.x0, transform_matrix.y0);
+  graphene_matrix_multiply (&m2, &m1, &m3);
+  graphene_matrix_init_translate (&m2, &(graphene_point3d_t)GRAPHENE_POINT3D_INIT(- width / 2.0, - height / 2.0, 0));
+  graphene_matrix_multiply (&m2, &m3, &m1);
+  gtk_snapshot_transform (snapshot, &m1);
 
   if (!_gtk_css_shadows_value_is_none (shadows))
     {
@@ -276,7 +276,7 @@ gtk_css_style_snapshot_icon_texture (GtkCssStyle *style,
 {
   const GtkCssValue *shadows, *transform;
   cairo_matrix_t transform_matrix;
-  graphene_matrix_t matrix, other, saved_matrix;
+  graphene_matrix_t m1, m2, m3, saved_matrix;
   graphene_rect_t bounds;
   GskRenderNode *node;
   int width, height;
@@ -296,14 +296,14 @@ gtk_css_style_snapshot_icon_texture (GtkCssStyle *style,
   graphene_matrix_init_from_matrix (&saved_matrix, gtk_snapshot_get_transform (snapshot));
 
   /* XXX: Implement -gtk-icon-transform-origin instead of hardcoding "50% 50%" here */
-  graphene_matrix_init_translate (&matrix, &(graphene_point3d_t)GRAPHENE_POINT3D_INIT(width / 2.0, height / 2.0, 0));
-  graphene_matrix_init_from_2d (&other, transform_matrix.xx, transform_matrix.yx,
-                                        transform_matrix.xy, transform_matrix.yy,
-                                        transform_matrix.x0, transform_matrix.y0);
-  graphene_matrix_multiply (&other, &matrix, &matrix);
-  graphene_matrix_init_translate (&other, &(graphene_point3d_t)GRAPHENE_POINT3D_INIT(- width / 2.0, - height / 2.0, 0));
-  graphene_matrix_multiply (&matrix, &other, &matrix);
-  gtk_snapshot_transform (snapshot, &matrix);
+  graphene_matrix_init_translate (&m1, &(graphene_point3d_t)GRAPHENE_POINT3D_INIT(width / 2.0, height / 2.0, 0));
+  graphene_matrix_init_from_2d (&m2, transform_matrix.xx, transform_matrix.yx,
+                                     transform_matrix.xy, transform_matrix.yy,
+                                     transform_matrix.x0, transform_matrix.y0);
+  graphene_matrix_multiply (&m2, &m1, &m3);
+  graphene_matrix_init_translate (&m2, &(graphene_point3d_t)GRAPHENE_POINT3D_INIT(- width / 2.0, - height / 2.0, 0));
+  graphene_matrix_multiply (&m2, &m3, &m1);
+  gtk_snapshot_transform (snapshot, &m1);
 
   graphene_rect_init (&bounds, 0, 0, width, height);
 
index 3f2fd4b93b8e76d328cec57039c9d1da0687099d..fe3500c14f2c537de13fa14cb2aa837ffaa9dea4 100644 (file)
@@ -151,7 +151,7 @@ gtk_snapshot_transform (GtkSnapshot             *state,
 {
   graphene_matrix_t result;
 
-  graphene_matrix_multiply (&state->transform, transform, &result);
+  graphene_matrix_multiply (transform, &state->transform, &result);
   graphene_matrix_init_from_matrix (&state->transform, &result);
 }